package cn.lix.sc.rpc.client.impl.rpc;

import cn.lix.sc.rpc.impl.common.constant.SystemCnt;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.slf4j.MDC;

public class FeignRequestInterceptor implements RequestInterceptor {

    @Override
    public void apply(RequestTemplate requestTemplate) {
        String info = MDC.get(SystemCnt.REQ_ID);
        // 将请求ID带到rpc服务端
        if(info == null){
            return;
        }
        requestTemplate.header(SystemCnt.REQ_ID, info);
    }

}
